package com.tim.helper;

import lombok.extern.slf4j.Slf4j;
import org.junit.Before;
import org.junit.Test;
import redis.clients.jedis.GeoRadiusResponse;
import redis.clients.jedis.GeoUnit;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.params.GeoRadiusParam;

import java.util.List;

/**
 * @author Adminis
 * @date 2020年10月29日
 * DESC:
 */
@Slf4j
public class RedisCacheHelper {

	Jedis jedis;

	@Before
	public void init() {
//		useTest();
		useDev();
//		useBugfix();
	}

	@Test// 消息模板
	public void getMsgCache() {
		String key = "";
		System.out.println(key);
		String result = jedis.get(key);
		System.out.println(result);
	}

	@Test
	public void redisGeo(){
		List<GeoRadiusResponse> list = jedis.georadius("",
					0, 0,
				10000, GeoUnit.M,
				GeoRadiusParam.geoRadiusParam().withCoord().withDist());
		System.out.println(list);
	}

    public void useDev() {
        String host = "47.114.170.170";
        int port = 6379;
        String pwd = "hvcQ^hCN5zVJ";
        jedis = new Jedis(host, port);
        jedis.auth(pwd);
        jedis.connect();

    }

	public void useTest() {
		String host = "116.62.208.87";
		int port = 6379;
		String pwd = "hvcQ^hCN5zVJ";
		jedis = new Jedis(host, port);
		jedis.auth(pwd);
		jedis.connect();

	}

	public void useBugfix() {
		String host = "47.111.237.5";
		int port = 6379;
		String pwd = "hvcQ^hCN5zVJ";
		jedis = new Jedis(host, port);
		jedis.auth(pwd);
		jedis.connect();
		jedis.select(1);

	}

//	public void JedisCluster() {
//		JedisCluster jc = new JedisCluster();
//		jc.auth(password)
//	}
}
